<%@page language="java" pageEncoding="UTF-8"%>
<%@taglib uri="/WEB-INF/tld/c.tld" prefix="c"%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
	<head>
		<title>My JSP 'roundSearch.jsp' starting page</title>

		<meta http-equiv="pragma" content="no-cache">
		<meta http-equiv="cache-control" content="no-cache">
		<meta http-equiv="expires" content="0">
		<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
		<meta http-equiv="description" content="This is my page">
		<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->
		<script type="text/javascript"
			src="http://api.map.baidu.com/api?v=1.3"></script>
	</head>

	<body>
		<div>
			<div>
				<div style="width: 520px; height: 340px; border: 1px solid gray"
					id="mapContainer">
				</div>
				<div>
					<div>
						<div>
							出发地信息
							<table>
								<tr>
									<td>
										省份
										<br>
									</td>
									<td>
										<input type="text" name="dep_province" value="" readOnly
											id="dep_province" />
										<br>
									</td>
								</tr>
								<tr>
									<td>
										城市
										<br>
									</td>
									<td>
										<input type="text" name="dep_city" value="" readOnly
											id="dep_city" />
										<br>
									</td>
								</tr>
								<tr>
									<td>
										区县
										<br>
									</td>
									<td>
										<input type="text" name="dep_district" value="" readOnly
											id="dep_district" />
										<br>
									</td>
								</tr>
								<tr>
									<td>
										街道
										<br>
									</td>
									<td>
										<input type="text" name="dep_street" value="" readOnly
											id="dep_street" />
										<br>
									</td>
								</tr>
								<tr>
									<td>
										门牌号
										<br>
									</td>
									<td>
										<input type="text" name="dep_streetNumber" value="" readOnly
											id="dep_streetNumber" />
										<br>
									</td>
								</tr>
								<tr>
									<td>
										<form action="roundSearch.do" method="post">
											<input name="x" value="" id="dep_x" type="hidden" />
											<input name="y" value="" id="dep_y" type="hidden" />
											<input type="submit" value="查找" />
										</form>
									</td>
									<td>
									</td>
								</tr>
							</table>
						</div>
					</div>
				</div>
			</div>
	</body>
</html>

<script type="text/javascript">
	//出发地地图
	var departureMap = new BMap.Map("mapContainer");
	departureMap.centerAndZoom(new BMap.Point(116.404, 39.915), 12);
	departureMap.addControl(new BMap.NavigationControl());
	departureMap.addControl(new BMap.ScaleControl());
	departureMap.addControl(new BMap.OverviewMapControl());
	departureMap.enableScrollWheelZoom();

	function departureIPAddress(result) {
		var cityName = result.name;
		departureMap.setCenter(cityName);
	}

	var departureCity = new BMap.LocalCity();
	departureCity.get(departureIPAddress);

	var departureGC = new BMap.Geocoder();
	departureMap
			.addEventListener(
					"click",
					function(e) {
						var point = e.point;
						departureGC
								.getLocation(
										point,
										function(rs) {
											var addComp = rs.addressComponents;
											if (confirm(addComp.province + ", "
													+ addComp.city + ", "
													+ addComp.district + ", "
													+ addComp.street + ", "
													+ addComp.streetNumber)) {
												departureMap.clearOverlays();
												departureMap
														.addOverlay(new BMap.Marker(
																point));
												document
														.getElementById('dep_province').value = addComp.province;
												document
														.getElementById('dep_city').value = addComp.city;
												document
														.getElementById('dep_district').value = addComp.district;
												document
														.getElementById('dep_street').value = addComp.street;
												document
														.getElementById('dep_streetNumber').value = addComp.streetNumber;
												document
														.getElementById('dep_x').value = point.lng;
												document
														.getElementById('dep_y').value = point.lat;
											}
										});
					});
</script>